from django.db import models


class ShopCategoryModel(models.Model):
    shop_category_id = models.IntegerField(primary_key=True)
    category_name = models.CharField(max_length=128)
    created_time = models.DateTimeField(auto_now_add=True)
    status = models.IntegerField()

    class Meta:
        db_table = 'shop_category'


class ChildCategoryModel(models.Model):
    child_category_id = models.IntegerField(primary_key=True)
    shop_category = models.ForeignKey('ShopCategoryModel', models.DO_NOTHING, blank=True, null=True)
    child_name = models.CharField(max_length=128)
    created_time = models.DateTimeField(auto_now_add=True)
    status = models.IntegerField(blank=True, null=True)

    class Meta:
        db_table = 'child_category'


class ShopsModel(models.Model):
    shop_id = models.BigIntegerField(primary_key=True)
    child_category = models.ForeignKey('ChildCategoryModel', models.DO_NOTHING, blank=True, null=True)
    shop_name = models.CharField(max_length=128)
    status = models.IntegerField()
    pic_url = models.CharField(max_length=256)
    box_cost = models.DecimalField(max_digits=32, decimal_places=0, blank=True, null=True)
    shipping_fee = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
    min_price = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
    score = models.DecimalField(max_digits=10, decimal_places=0)
    avg_delivery_time = models.IntegerField()
    info = models.CharField(max_length=128, blank=True, null=True)
    announcement = models.CharField(max_length=1024, blank=True, null=True)
    total_sales = models.IntegerField(blank=True, null=True)
    month_sales = models.IntegerField(blank=True, null=True)
    latitude = models.DecimalField(max_digits=64, decimal_places=0, blank=True, null=True)
    longitude = models.DecimalField(max_digits=64, decimal_places=0, blank=True, null=True)
    address = models.CharField(max_length=512)
    average_price_tip = models.IntegerField()

    class Meta:
        db_table = 'shops'


class ShopActivityModel(models.Model):
    shop_activity_id = models.IntegerField(primary_key=True)
    shop = models.ForeignKey('ShopsModel', on_delete=models.DO_NOTHING, blank=True, null=True)
    type = models.IntegerField(blank=True, null=True)
    target = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
    cut = models.DecimalField(max_digits=10, decimal_places=0)
    status = models.IntegerField(default=1)
    created_time = models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table = 'shop_activity'


class BannerModel(models.Model):
    banner_id = models.IntegerField(primary_key=True)
    pic_url = models.CharField(max_length=128)
    pic_name = models.CharField(max_length=128)
    created_time = models.DateTimeField(blank=True, null=True)
    status = models.IntegerField(blank=True, null=True)

    class Meta:
        db_table = 'banner'


class CouponModel(models.Model):
    coupon_id = models.IntegerField(primary_key=True)
    shop = models.ForeignKey(ShopsModel, on_delete=models.DO_NOTHING, blank=True, null=True)
    type = models.IntegerField(blank=True, null=True)
    title = models.CharField(max_length=32, blank=True, null=True)
    target_money = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
    discount_money = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
    end_time = models.DateTimeField(blank=True, null=True)
    add_time = models.DateTimeField(blank=True, null=True)
    number = models.IntegerField(blank=True, null=True)
    status = models.IntegerField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'coupon'



